package com.basic.java.spring5.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * 类
 * 创建时间：2022/3/6 18:26
 *
 * @author gejin
 */
public class BeanLifeCycleProcessor implements BeanPostProcessor {
    /**
     * 初始化前处理
     *
     * @param bean
     * @param beanName
     * @return
     * @throws BeansException
     */
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("第三步 执行postProcessBeforeInitialization方法");
        return bean;
    }

    /**
     * 初始化后处理
     *
     * @param bean
     * @param beanName
     * @return
     * @throws BeansException
     */
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("第五步 执行postProcessAfterInitialization");
        return bean;
    }
}
